<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
   pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="support.*,java.util.*"%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="layout.css" />

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Degree Form</title>
</head>
<body>
   <%
      student applicant = (student) session.getAttribute("applicant");
      //add a new degree to the map with the counter
      int count = (Integer) session.getAttribute("count");
      applicant.degreeMap.put(count, applicant.new Degree());

      int marker = Integer.parseInt((String) request
            .getParameter("stateCon"));
      applicant.degreeMap.get(count).setDegreeLocation(marker);

      support s = new support();

      //set the tuple in the main class
      applicant.degreeMap.get(count).setTuple(
            ((Vector) applicant.getUniversityVector().get(
                  applicant.degreeMap.get(count).getDegLocation())));

      //set the state/country of the degree
      applicant.degreeMap.get(count).setState();

      //setup the vector with only universities
      applicant.degreeMap.get(count).setOnlyUniversities();
   %>
   
   <h1>Degree - University</h1>
   <hr>
   <p><b>Please Choose your university from the list below:</b></p>


   <table border="1">
      <%
         int size = applicant.degreeMap.get(count).onlyUniversities.size(), rows, cell1, cell2, cell3;

         if (applicant.degreeMap.get(count).onlyUniversities.size() % 3 == 0)
            rows = (int) (size / 3);
         else
            rows = (int) (size / 3) + 1;

         for (int i = 0; i < rows; i++) {
            cell1 = i;
            cell2 = i + rows;
            cell3 = i + 2 * rows;
      %>
      <tr>
         <td><a href="degreeDis.jsp?university=<%=cell1%>"><%=applicant.degreeMap.get(count).onlyUniversities
                  .get(cell1)%></a></td>
         <%
            if (cell2 < size) {
         %>
         <td><a href="degreeDis.jsp?university=<%=cell2%>"><%=applicant.degreeMap.get(count).onlyUniversities
                     .get(cell2)%></a></td>
         <%
            }
               if (cell3 < size) {
         %>
         <td><a href="degreeDis.jsp?university=<%=cell3%>"><%=applicant.degreeMap.get(count).onlyUniversities
                     .get(cell3)%></a></td>
         <%
            }
         %>
      </tr>
      <%
         }
      %>
   </table>

   <form method="POST" action="degreeDis.jsp">
      <p>Or, enter your own university: <input type="text" name="custUniversity" /></p>
      <input type="submit" class="floatright" value="Submit" />
   </form>


</body>
</html>